package structure.composite;

/**
 * @author dali
 * @date 2021-07-19 16:01
 * @Description 客户端
 */

public class Client {
    public static void main(String[] args) {
        Component company = new CompanyComposite("北京公司");
        Component dept1 = new DeptComposite("财务部");
        Component dept2 = new DeptComposite("市场部");
        Component leaf = new Leaf("最小部门");
        //将部门加到公司中
        company.add(dept1);
        company.add(dept2);

        //将最小部门加到部门中
        dept1.add(leaf);
        dept2.add(leaf);

        //输出组织架构
        company.getChild();
        System.out.println("-------");
        dept1.getChild();
    }
}
